#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int MAXN = 2e5+10;

int n,ans[MAXN],K,L,bl1[MAXN],bl2[MAXN],num1,num2,x,y;
vector<int> G[MAXN],T[MAXN];
map<int,map<int,int>> p;

void dfs1(int x){
	bl1[x] = num1;
	for(int y : G[x]){
		if(!bl1[y]) dfs1(y);
	}
}

void dfs2(int x){
	bl2[x] = num2;
	for(int y : T[x]){
		if(!bl2[y]) dfs2(y);
	}
}
		
int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
    n = in;K = in;L = in;
	for(int i = 1;i <= K;i++){
		x = in,y = in;
		G[x].pb(y); G[y].pb(x);
	}
	for(int i = 1;i <= L;i++){
		x = in,y = in;
		T[x].pb(y);T[y].pb(x);
	}
	for(int i = 1;i <= n;i++) if(!bl1[i]) ++num1,dfs1(i);
	for(int i = 1;i <= n;i++) if(!bl2[i]) ++num2,dfs2(i);
	for(int i = 1;i <= n;i++) p[bl1[i]][bl2[i]]++;
	for(int i = 1;i <= n;i++) printf("%d%c",p[bl1[i]][bl2[i]]," \n"[i==n]);
	return 0;
}
